#include<iostream>
#include<algorithm>
using namespace std;
const int N = 1010;
int arr[N];
int n;
int main()
{
	cin >> n;
	int ma = 0;
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
	}
	int f = 0;
	for (int i = 1; i <= n; i++) {
		if (!arr[i]) {
			f = 0;
		}
		else if (arr[i] != arr[i - 1]) {
			f = 1;
		}
		else {
			f++;
		}
		ma = max(ma, f * arr[i]);
	}
	cout << ma << endl;
	return 0;
}